<template>
	<view>
		<uni-nav-bar :statusBar="true" rightText="发布" left-icon="back" @clickLeft="back" @clickRight="submit">
			<view class="u-f-ajc" @tap="changelook">
				<view>{{yinsi}}</view>
				<view class="icon iconfont icon-xialazhankai"></view>
			</view>
		</uni-nav-bar>
		<view class="uni-textarea">
			<textarea placeholder="说一句话吧~" v-model="text"></textarea>
		</view>
		<uploud-images @uploud="uploud"></uploud-images>
		<uni-popup ref="popup">
			<view class="gonggao">
				<view class="u-f-ajc">
					<image src="../../static/common/addinput.png" mode="widthFix"></image>
				</view>
				<view class="tip">
					<view>1.涉及黄色，政治，广告及骚扰信息</view>
					<view>2.涉及黄色，政治，广告及骚扰信息</view>
					<view>3.涉及黄色，政治，广告及骚扰信息</view>
					<view>4.涉及黄色，政治，广告及骚扰信息</view>
				</view>
				<button type="default" @tap="hidePopup">朕知道了</button>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	let changelook = ['所有人可见', '仅自己可见'];
	import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue";
	import uploudImages from "../../components/common/uploud-images.vue";
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	export default {
		components: {
			uniNavBar,
			uploudImages,
			uniPopup
		},
		data() {
			return {
				isget:false,
				showpopup:true,
				yinsi: "所有人可见",
				text:"",
				imglist:[]
			}
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				});
			},
			submit() {
				this.$refs.popup.open();
				console.log("发布");
			},
			changelook() {
				uni.showActionSheet({
					itemList: changelook,
					success: (res) => {
						this.yinsi = changelook[res.tapIndex];
					}
				});
			},
			uploud(arr){
				this.imglist=arr;
				console.log(this.imglist)
			},
			hidePopup(){
				this.$refs.popup.close()
			},
			baocun(){
				uni.showModal({
					content: '是否要保存为草稿？',
					cancelText: '取消',
					confirmText: '保存',
					success: res => {
						if(res.confirm){
							console.log("保存");
						}else{
							console.log("取消");
						}
						this.isget = true;
						uni.navigateBack({
							delta:1
						})
					}
				});
			}
		},
		onBackPress() {
			if(!this.text && this.imglist.length == 0) {
				return;
			}
			if(!this.isget){
				this.baocun();
				return true;
			}
		}
	}
</script>

<style lang="scss">
	.uni-textarea {
		border: 1rpx solid #EEEEEE;
	}

	.cell-pd {
		padding: 22rpx 30rpx;
	}

	.list-pd {
		margin-top: 50rpx;
	}
	
	.uni-uploader__file{
		position: relative;
	}
	
	.icon-shanchu{
		position: absolute;
		right: 0;
		top: 0;
		background: #333333;
		color: #FFFFFF;
		padding: 2rpx 10rpx;
		border-radius: 10rpx;
	}
	
	.gonggao{
		width:500rpx;
		background: #FFFFFF;
		height: 100%;
		image{
			width: 75%;
			margin-bottom: 20rpx;
			margin-top: 10rpx;
		}
		.tip{
			margin: 0rpx 28rpx;
		}
		button{
			background: #FFE934;
			color: #171606;
			margin-top: 20rpx;
			width: 75%;
			margin-bottom: 20rpx;
		}
	}
</style>
